﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using WebAPIClientDemo;

namespace TestWeb.WebForm
{
    public partial class Index : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }
        RestClient client = new RestClient("http://localhost:29331");
        string url = "";
        string data = "";
        protected void Button1_Click(object sender, EventArgs e)
        {
            #region Get 方式请求列表
             url=this.TextAreaRequest1.InnerText.Trim();
             string str = client.Get(url);
            this.TextArea1.Value = str;
            //Console.WriteLine(str);
            #endregion
        }

        protected void Button2_Click(object sender, EventArgs e)
        {
            #region Get 方式请求id对应的数据
            url = this.TextAreaRequest2.InnerText.Trim();
           
            string strGetById = client.Get(url);
            this.TextArea2.Value = strGetById;
            #endregion
        }

        protected void Button3_Click(object sender, EventArgs e)
        {
            #region Post 方式 添加数据
            url = this.TextAreaRequest3.InnerText;


            data = this.TextAreaRequest6.InnerText;
            string postResponse = client.Post(data, url);
            this.TextArea3.Value = postResponse;
            #endregion

        }

        protected void Button4_Click(object sender, EventArgs e)
        {
            #region 删除
            url = this.TextAreaRequest4.InnerText;
            string deleteResponse = client.Delete(url);
            this.TextArea4.Value = deleteResponse;
            #endregion
        }

        protected void Button5_Click(object sender, EventArgs e)
        {
            #region 修改
            url = this.TextAreaRequest5.InnerText;
            data = this.TextAreaRequest7.InnerText; ;
            string putResponse = client.Post(data, url);
            this.TextArea5.Value = putResponse;
            #endregion
        }
    }
}